import store from '@/store'

export default {

  inserted(el, binding, vnode) {
    const { value } = binding

    const Permission = store.getters.permissions

    if (value) {
      if(Permission.indexOf(value) != -1){
        return true;
      }else {
        if (store.getters.name != 'admin'){
          el.parentNode && el.parentNode.removeChild(el)

        }
      }
    } else {
      throw new Error(`need roles! Like v-permission="'admin'"`)
    }
  }
}
